package CaseDemos;

/**
 * 比较两个数组中的内容是hi否一样，一样返回true，反之返回false
 * 用方法实现
 */

public class MethodTest {
    public static void main(String[] args){
        int[] arr1 = {1,2,3,4,5};
        int[] arr2 = {1,2,3,4,5};
        int[] arr3 = {1,2,3,4,5,6};
        int[] arr4 = {2,3,4,5,6};

        System.out.println("arr1 and arr2 is " + compareArrays(arr1, arr2));
        System.out.println("arr1 and arr3 is " + compareArrays(arr1, arr3));
        System.out.println("arr1 and arr4 is " + compareArrays(arr1, arr4));
    }

    public static boolean compareArrays(int[] arr1, int[] arr2){
        if (arr1.length == arr2.length) {
            for(int i = 0; i < arr1.length; i++){
                if(arr1[i] != arr2[i]){
                    return false;
                }
            }
            return true;
        }else {
            return false;
        }
    }
}
